<?php //MODULES 
 switch ($_REQUEST[module]) {
   case 'counts':
		if(!checkQualified("0400")) { print "You are not allowed to perform this action! (You=" . $_SESSION[permission] . " : Req'd=0400)"; break; } 
?>
			 <!-- Passenger Counts Module -->
			 <!-- Bus lines must propagate from lines table in db, to make fully customizable -->
			 <h6 align="center">Passenger Counts</h6>
			 <div align="center" style="margin: 5px"><select name="hour">
                <option value="0700">0700</option>
                <option value="0800">0800</option>
                <option value="0900">0900</option>
                <option value="1000">1000</option>
                <option value="1100">1100</option>
                <option value="1200">1200</option>
                <option value="1300">1300</option>
                <option value="1400">1400</option>
                <option value="1500">1500</option>
                <option value="1600">1600</option>
                <option value="1700">1700</option>
                <option value="1800">1800</option>
                <option value="1900">1900</option>
                <option value="2000">2000</option>
                <option value="2100">2100</option>
                <option value="2200">2200</option>
                <option value="2300">2300</option>
                <option value="2400">2400</option>
              </select></div>
			 <div align="center" style="margin: 5px">
			   <table>
			     <tr>
				   <th>Line</th>
				   <th>Count</th>
				 </tr>
				 <tr>
				   <td>Blue 1</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Blue 2</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Blue 3</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Red 1</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Red 2</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Red 3</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Green 1</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Green 2</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Green 3</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Yellow</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   
                  <td>Apt 1</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
                  <td>Apt 2</td>
				   <td align="center"><input name="blue1" type="text" size="5"></td>
				 </tr>
				 <tr>
				   <td colspan="2" align="center"><input name="save" type="submit" value="Save Counts"></td>
				 </tr>
			   </table>
			 </div>
			 <!-- End Passenger Counts Module -->
<?php
       break;
   case 'rules':
    /*$sql = "SELECT * FROM `t_sched_groups` WHERE `group_id` = " . $_REQUEST['group'];
	$result = mysql_query($sql);
	$data = mysql_fetch_assoc($result);*/
	$rules_file = SYSROOT . 'rules/' . $_REQUEST['group_id'] . '.htm';
	if(is_file($rules_file)) {
	
	echo '<form action="' . $_SERVER["PHP_SELF"] . '?task=acceptRules&amp;signup_id=' . $_REQUEST['signupid'] . '&amp;group_id=' . $_REQUEST['group_id'] . '&amp;sched=pick_day" method="post" name="form1" id="form1">';
	echo "<table>";
	
	$fh = fopen($rules_file, 'r');
	$rules_file_data = fread($fh, filesize($rules_file));
	$rules_file_data = str_replace("<ul type=square>", "<tr><td valign='top'><input type='checkbox' name='agreeToRules' style='margin-top: 7px'></td><td valign='top'><ul type=square>", $rules_file_data);
	$rules_file_data = str_replace("<ul type=circle>", "<tr><td></td><td><ul type=circle>", $rules_file_data);
	$rules_file_data = str_replace("</ul>", "</td></tr>", $rules_file_data);
	fclose($fh);
	echo $rules_file_data;
	
	echo "</table>";
	
	
		//include($rules_file);
		?><div align="center">
		<script type="text/javascript">
		<!--
		function checkAgree(){
			totalBoxes = document.form1.agreeToRules.length;
			
			for (i = 0; i < totalBoxes; i++) {
				if (!document.form1.agreeToRules[i].checked) {
					alert('You must agree to all of the rules before signing up!');
					return false;
				}
			}
			
			return true;
		}
		-->
		</script>
		<br /><br />You must mark each checkbox before continuing.<br />
		<input type="submit" value="Accept Rules and Continue to Signups" onclick='return checkAgree()'></form></div><?php
	} else {
		print "That rules file does not exist!";
		print "<!-- " . $rules_file . " -->\n";
	}
	

       break;
   case 'signup_sched':
		if(!checkQualified("0000")) { print "You are not allowed to perform this action! (You=" . $_SESSION[permission] . " : Req'd=0000)"; break; } 

		$group = $_REQUEST['group'];
		$result = mysql_query("SELECT *
FROM `t_sched_groups` , `t_drivers` , `t_sched_signups`
WHERE `t_sched_groups`.`group_id` = $group
AND `t_sched_groups`.`group_id` = `t_sched_signups`.`group_id`
AND `t_sched_signups`.`driver_id` = `t_drivers`.`driver_id`
ORDER BY `t_sched_signups`.`date` ASC , `t_sched_signups`.`time` ASC");
		$num_of_signups = mysql_num_rows($result);
?>
<div style="text-align:center; margin:10px; font-size: 14px; font-weight:bold; ">Signup Schedule</div>
<div style="text-align:center; ">
<table style="margin:auto; margin-bottom: 20px;" cellpadding="3" cellspacing="0">
<?php
//$first = true;
while(		$row = mysql_fetch_assoc($result) ) {
	
	if($lastDate != $row['date']) {
//		if(!$first) print "</table>\n";
	  print "<tr><th colspan=2 style='border: 2px solid black;'>" . formatDate_long($row['date']) . "</th></tr>\n";
	  $lastDate = $row['date'];
	}
	if(--$num_of_signups == 0)
		$additional_borders = ' border-bottom: 2px solid black;';
	print "<tr><td style='border-left: 2px solid black; text-align: left;".$additional_borders."'>"  . $row['lastname'] . ", " . $row['firstname'] ."</td><td style='border-right: 2px solid black;".$additional_borders."'>" . $row['time'] . "</td></tr>\n";
//	$first = false;
}
?>
</table>
</div>
<?php       break;
   case 'editmenus':
?>
			 <!-- Edit Menus Module -->
			 <h6 align="center">Sidebar Options</h6>
			 <div align="center">
			   You have the following sidebars available:
			 </div>
<?php 	if(checkQualified('1000')) { ?>
			 <div align="center">
			   <a href="?task=changemenu&menu=amops">AM of Ops</a>
			 </div>
<?php 	} 
		if(checkQualified('0400')) { ?>
			 <div align="center">
			   <a href="?task=changemenu&menu=dispatcher">Dispatcher</a>
			 </div>
<?php 	} 
		if(checkQualified('0100')) { ?>
			 <div align="center">
			   <a href="?task=changemenu&menu=pm">Preventative Maintanence</a>
			 </div>
<?php 	} 
		if(checkQualified('0200')) { ?>
			 <div align="center">
			   <a href="?task=changemenu&menu=trainer">Trainer</a>
			 </div>
<?php 	}  ?>
			 <!-- End Edit Menus Module -->
<?php
       break;
	case 'my_shifts':
		if(isset($_REQUEST['override']) && checkQualified("1000")) {
			$driver = $_REQUEST['override'];
			if(DEBUG) print "Overriding user: " . $driver;
		} else {
			$driver = $_SESSION['driver_id'];
		}
		$result = mysql_query("SELECT `t_sched_groups`.`description` as group_desc, `t_sched_main`.`description` as day_desc, `t_sched_main`.`week`, `t_sched_structure`.`description` as line_desc, `t_sched_structure`.`start`, `t_sched_shifts`.* FROM `t_sched_groups`, `t_sched_main`, `t_sched_structure`, `t_sched_shifts` 
			WHERE `t_sched_groups`.`group_id` = `t_sched_main`.`group_id`
			AND `t_sched_main`.`table_id` = `t_sched_structure`.`table_id`
			AND `t_sched_structure`.`structure_id` = `t_sched_shifts`.`structure_id`
			AND `t_sched_shifts`.`driver_id` = $driver
			AND `t_sched_groups`.`status` > 0
			ORDER BY `t_sched_groups`.`group_id` DESC, `t_sched_main`.`order` ASC, `t_sched_shifts`.`shift_start` ASC");
		if(checkQualified("1000")) {
			?>
			<div style="text-align:center; margin:20px;">
			  <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
				<option value="<?=$_SESSION['driver_id']?>" selected> - Change Employee - </option>
				<?php
					$driver_sql = "SELECT `driver_id` , concat( `lastname` , \", \", `firstname` ) AS name FROM t_drivers WHERE `terminated` IS NULL ORDER BY `lastname` ASC, `firstname` ASC";
					$driver_result = mysql_query($driver_sql);
					while($driver_data = mysql_fetch_assoc($driver_result)) {
						print "    <option value=\"?module=my_shifts&amp;override=" . $driver_data['driver_id'] . "\">" . $driver_data['name'] . "</option>\n";
					}
					mysql_free_result($driver_result);
				?>
			  </select>
			</div>
		<?php
		} // end check qualified
		if($driver == $_SESSION['driver_id']) {
		?>
		<h1 style="text-align:center; ">Your Shifts</h1>
		<?php
		} else {
		?>
		<h1 style="text-align:center; "><?= driverName($driver) ?>'s Shifts</h1>
		<?php
		}
		while($row = mysql_fetch_assoc($result)) {
			if($lastGroup != $row['group_desc']) {
				if($inLoop == true) {
					//if they already printed some stuff, close the last one first!
					?>
			<tr>
				<td colspan=2 style="text-align:right; padding-right:10px;">Week Total</td>
				<td style="text-align:right; padding: 5px; font-weight: bold; "><?php print sprintf("%01.2f",$weekTotal); ?></td>
			</tr>
		</table>
</span>
					<?php
					$weekTotal = 0;
				}

				?>
<span style="display: block; width: 400px; border:thin solid #000066; background-color:#AAAAFF; padding: 15px; margin: 10px auto 10px auto; text-align:center;"> <!-- group breakup -->
	<h2 style="text-align:center; "><?= $row['group_desc'] ?></h2>
				<?php
				$lastGroup = $row['group_desc'];
				unset($lastWeek);
				$inLoop = false;
			}
			if($lastWeek != $row['week']) {
				if($inLoop) {
					?>
			<tr>
				<td colspan=2 style="text-align:right; padding-right:10px;">Week Total</td>
				<td style="text-align:right; padding: 5px; font-weight: bold; "><?php print sprintf("%01.2f",$weekTotal); ?></td>
			</tr>
		</table>
					<?php
					$weekTotal = 0;
				}
				?>
		<table style="border:thin solid black; background-color:#eeeeee; padding: 15px; margin-top: 15px; margin-bottom: 15px; margin-left: auto; margin-right: auto; width: 350px;">
				<?php
				$lastWeek = $row['week'];
			}
			if($lastDay != $row['day_desc']) {
				?>
			<tr>
				<td colspan=3><?= $row['day_desc'] ?></td>
			</tr>
				<?php
				$lastDay = $row['day_desc'];
			}
			if($row['start'] == $row['shift_start']) { //don't add 10 minutes.. this is an opening shift
				$shiftLength = paylogTime($row['shift_end']) - paylogTime($row['shift_start']);
				//if(checkQualified(4000)) print " <!-- Paylog Calculation: " . paylogTime($row['shift_end']) . " - " . paylogTime($row['shift_start']) . " = " . paylogTime($row['shift_end']) - paylogTime($row['shift_start']) . " --> ";
			} else {
				$shiftLength = paylogTime($row['shift_end']) - paylogTime(subtractTime($row['shift_start'],0010));
				//if(checkQualified(4000)) print " <!-- Paylog Calculation: " . paylogTime($row['shift_end']) . " - " . paylogTime(subtractTime($row['shift_start'],0010)) . " = " . paylogTime($row['shift_end']) - paylogTime(subtractTime($row['shift_start'],0010)) . " --> ";
			}
			$weekTotal += $shiftLength;
			?>
			<tr>
				<td style="padding-left:20px; width: 150px; text-align:left; font-size: 12px;"><?= $row['line_desc'] ?></td>
				<td style="padding: 5px;  font-size: 12px;"><?= formatOutputTime($row['shift_start']) ?> - <?= formatOutputTime($row['shift_end']) ?></td>
				<td style="text-align:right; padding-right: 5px; font-size: 12px; "><?= $shiftLength ?></td>
			</tr>
			<?php
			$inLoop = true;
		}
	?>


			<tr>
				<td colspan=2 style="text-align:right; padding-right:10px;">Week Total</td>
				<td style="text-align:right; padding: 5px; font-weight: bold; "><?php print sprintf("%01.2f",$weekTotal); ?></td>
			</tr>
		</table>
</span> <!-- group breakup -->

<?php
       break;
   case 'contact_info':
?>
	<table style="margin-left: auto; margin-right: auto; margin-top: 20px; margin-bottom: 20px;">
		<tr>
			<td colspan="3" style="font-weight:bold; text-align:center;">Important Numbers</td>
		</tr>
		<tr>
			<th>Location/Person</th>
			<th>Phone Number</th>
			<th><div align="center">Email</div></th>
		</tr>
		<tr>
			<td>Dispatch</td>
			<td>(860) 486-6924</td>
			<td><div align="center">n/a</div></td>
		</tr>
		<tr>
			<td>Janet</td>
			<td>(860) 486-4804</td>
			<td><div align="center"><a href="mailto:janet.freniere@uconn.edu">janet.freniere@uconn.edu</a></div></td>
		</tr>
		<tr>
		  <td>Erin Lirot </td>
		  <td>(860) 486-6902</td>
		  <td><div align="center"><a href="mailto:erin.lirot@uconn.edu">erin.lirot@uconn.edu</a></div></td>
	  </tr>
		<tr>
		  <td>Coordinator of Ops <br>
		    <div style="text-indent: 20px; ">Matt Scibek</div></td>
		  <td>(860) 486-6685 </td>
		  <td><div align="center"><a href="mailto:amopsii@park.uconn.edu">amopsii@park.uconn.edu</a></div></td>
	  </tr>
		<tr>
		  <td>Coordinator of Training<br>
		    <div style="text-indent: 20px; ">Eddie Silva</div></td>
		  <td>(860) 486-6706</td>
		  <td><div align="center"><a href="mailto:amtrain@park.uconn.edu">amtrain@park.uconn.edu</a></div></td>
	  </tr>
		<tr>
		  <td>Coordinator of PM<br>
		    <div style="text-indent: 20px; ">Justin Torniero</div></td>
		  <td>(860) 486-6685 </td>
		  <td><div align="center"><a href="mailto:ampm@park.uconn.edu">ampm@park.uconn.edu</a></div></td>
	  </tr>
		<tr>
		  <td>Coordinator of Marketing<br>
	        <div style="text-indent: 20px; ">Clint Frost</div></td>
		  <td>(860) 486-6637</td>
		  <td><div align="center"><a href="mailto:admgr@park.uconn.edu">admgr@park.uconn.edu</a></div></td>
	  </tr>
		<tr>
		  <td colspan="2">Parking &amp; Transportation Website</td>
		  <td><div align="center"><a href="http://www.park.uconn.edu/" target="_blank">www.park.uconn.edu</a></div></td>
	  </tr>
	</table>
<?php
       break;
   case 'seniorityList':
?>
<div style="text-align:center; "><h1>Seniority List</h1></div>
<?php 
	if(!checkQualified("4000")) {
		alertText("Coming Soon...");
		break;
	}
?>
<div style="text-align:center; ">
	<table style="margin:auto; ">
		<tr>
			<th style="text-align:left; ">Rank</th>
			<th style="text-align:left; ">Employee</th>
			<th style="text-align:left; ">Points</th>
		</tr>
		<?php
			$sql = "SELECT `t_seniority`.`driver_id`, sum(`t_seniority`.`points`) POINTS, concat(`lastname`,', ',`firstname`) NAME 
					from t_seniority, t_drivers 
					where `t_seniority`.`driver_id` = `t_drivers`.`driver_id` and
					`t_drivers`.`signups_active` = 1
					group by t_seniority.driver_id 
					order by POINTS desc";
			$result = mysql_query($sql);
			$rank = 1;
			while($data = mysql_fetch_assoc($result)) {
				?>
		<tr>
			<td style="text-align:left; "><?= $rank ?></td>
			<td style="text-align:left; "><?= $data['NAME'] ?></td>
			<td style="text-align:right; "><?= $data['POINTS'] ?></td>
		</tr>
				<?php
				$rank ++;
			}
		?>
	</table>
</div>
<?php
	$sql  = "Show table status from transportation like 't_seniority'";
	$result = mysql_query($sql);
	$data = mysql_fetch_assoc($result);
	$date = date("l, M d, Y",strtotime($data['Update_time'])) . " at " . date("G:i",strtotime($data['Update_time']));
?>
<div style="text-align:center; " class="italic_1">Last Updated on <?=$date?>.</div>
<?php
       break;
   case 'memos':
?>
			 <!-- View Memos Module -->
			 <h6 align="center">Current Memos</h6>
<?php
  $sql = mysql_query("SELECT `t_drivers`.`firstname`, `t_drivers`.`lastname`, `t_memos`.* FROM `t_memos`,`t_drivers` WHERE `t_memos`.`driver_id` = `t_drivers`.`driver_id` AND `t_memos`.`display` = 1 AND `t_memos`.`expire_date` > " . date("Ymd"));
  if(mysql_num_rows($sql)) {
    //there were results, print memos
	print "<div align='center'><table width='400' align='center'><tr><td>\n";
	while($row = mysql_fetch_assoc($sql)) {
?>
            <!-- Start center-left blocks loop -->
		     <div style="padding: 0px 0px 0px 8px;">
			   <fieldset>
			     <legend style="padding: 3px;  font-weight: bold;"><?= $row['subject'] ?></legend>
				   <div align="left" class="italic_1" style="padding: 3px; line-height: 120%; line-height: 120%;">By <?= $row['first_name'] ?> <?= $row['last_name'] ?></div>
				   <div align="left" style="padding: 3px; line-height: 120%; line-height: 120%;"><?= $row['memo'] ?></div>
				   <div class="highlight" align="center"><a href="?module=memos&amp;markasread=<?= $row['memo_id'] ?>">Mark as Read</a></div>
			   </fieldset>
			 </div>         
			 <!-- End View Memos Module -->
<?php
    }
    print "</td></tr></table></div>\n";
  } else {
    //no results, alert them of this..
?>
		     <div align="center">There are no current memos.</div>
<?php
  }
  mysql_free_result($sql);
       break;
   case 'view_images':
?>
			 <!-- View Sample createpng.php images Module -->
			 <h6 align="center">Board Image Style Descriptions</h6>
			 <div align="center">
			 <table align="center">
			   <tr>
			     <td>Normal Shift</td>
				 <td><img src="<?= PNG_FILE ?>?start=1200&end=1445&type=S&name=Doe, John"></td>
			   </tr>
			   <tr>
			     <td>Your Shift</td>
				 <td><img src="<?= PNG_FILE ?>?start=1200&end=1445&type=M&name=Doe, John"></td>
			   </tr>
			   <tr>
			     <td>Open Shift (Before Signup Time)</td>
			     <td><img src="<?= PNG_FILE ?>?start=1200&end=1445&type=E"></td>
		       </tr>
			   <tr>
			     <td>Open Shift (After Signup Time)</td>
			     <td><img src="<?= PNG_FILE ?>?start=1200&end=1445&type=O"></td>
		       </tr>
			   <tr>
			     <td>Filler Image </td>
			     <td><img src="<?= PNG_FILE ?>?start=1200&end=1445&type=F"></td>
		       </tr>
			   <tr>
			     <td>Shutdown/Non-running Lines</td>
			     <td><img src="<?= PNG_FILE ?>?start=1200&end=1445&type=N"></td>
		       </tr>
			   <tr>
			     <td>Unavailable/not-eligible shift </td>
			     <td><img src="<?= PNG_FILE ?>?start=1200&end=1445&type=X"></td>
		       </tr>
			 </table>
			 </div>
			 <!-- End View Sample createpng.php images Module -->
<?php
       break;
   case 'manip_vars':
   //		if(!checkQualified("4000")) { print "You are not allowed to perform this action! (You=" . $_SESSION[permission] . " : Req'd=4000)"; break; } 

?>
			 <?php //if submitting changes
			   if(isset($_REQUEST[new_key])) {
			     foreach ($_REQUEST as $key => $value) {
				   if(substr($key,0,8) == 'session_') {
				     $key_name = substr($key,8,strlen($key) - 8);
					 $_SESSION[$key_name] = $value;
				   }
				 }
				 if($_REQUEST[new_key] != '') {
				   $_SESSION[$_REQUEST[new_key]] = $_REQUEST[new_value];
				 }
			   }
			 ?>
			 <!-- Manipulate Session Variables Module -->
			 <h6 align="center">Manipulate Session Variables</h6>
			 <div align="center" style="margin: 5px">
			 <form action="?module=manip_vars" method="post">
			   <table>
			   <?php
			     foreach ($_SESSION as $key => $value) {
			   ?>
			     <tr>
				   <td><?=$key?></td>
				   <td><input type="text" name="session_<?=$key?>" value="<?=$value?>"></td>
				 </tr>
			   <?php
				 }
			   ?>
			     <tr>
				   <td><input type="text" name="new_key" value=""></td>
				   <td><input type="text" name="new_value" value=""></td>
				 </tr>
				 <tr>
				   <td colspan="2"><input type="submit" value="Save Session Variables"></td>
				 </tr>

			   </table>
			 </form>
			 </div>
			 <!-- END Manipulate Session Variables Module -->
<?php
       break;
   case 'board':
			  if(isset($_REQUEST['date']) && ($_REQUEST['date'] != '')) {
			    $date = $_REQUEST['date'];
			  } else {
			    $date = date("Ymd");
			  }
			  if(isset($_REQUEST['day'])) {
			    $day = $_REQUEST['day'];
			  } else {
			    $day = date("w");
			  }
?>
			 <!-- Current Shift Board Module -->
			 <h6 align="center">Shift Board for <?= date("D, M j, Y",mktime(0,0,0,substr($date,4,2),substr($date,6,2),substr($date,0,4))) ?></h6>
			 <div align="center" style="margin: 5px">

			 <script language="javascript">
			 <!-- hide
			 function shiftInfo(id) {
			  window.open("misc.php?action=shiftInfo&id=" + id, "shiftInfo", "height=100,width=200,location=no,directories=no,menubar=no,resizable=yes,scrollbars=no,toolbar=no");
			 }
			 // -->
			 </script>
			 
			 
			 <table border=1 cellpadding=0 cellspacing=1> 
			 <?php
			  //figure out earliest shift, so we can put fillers in front of any others
			  $earliest = mysql_query("SELECT `t_sched_structure`.`start` FROM `t_sched_dates`,`t_sched_main`,`t_sched_structure` WHERE `t_sched_dates`.`date_id` = $date AND `t_sched_dates`.`table_id` = `t_sched_main`.`table_id` AND `t_sched_main`.`table_id` = `t_sched_structure`.`table_id` ORDER BY `t_sched_structure`.`start` ASC LIMIT 1");
			  $earliest_row = mysql_fetch_assoc($earliest);
			  $day_start_time = $earliest_row['start'];
			  
			  //figure out latest shift, so we can put fillers on end of any others
			  $latest = mysql_query("SELECT `t_sched_structure`.`end` FROM `t_sched_dates`,`t_sched_main`,`t_sched_structure` WHERE `t_sched_dates`.`date_id` = $date AND `t_sched_dates`.`table_id` = `t_sched_main`.`table_id` AND `t_sched_main`.`table_id` = `t_sched_structure`.`table_id` ORDER BY `t_sched_structure`.`end` DESC LIMIT 1");
			  $latest_row = mysql_fetch_assoc($latest);
			  $day_end_time = $latest_row['end'];
			  

			  $lines = mysql_query("SELECT `t_sched_main`.`table_id`,`t_sched_structure`.* FROM `t_sched_dates`,`t_sched_main`,`t_sched_structure` WHERE `t_sched_dates`.`date_id` = $date AND `t_sched_dates`.`table_id` = `t_sched_main`.`table_id` AND `t_sched_main`.`table_id` = `t_sched_structure`.`table_id` ORDER BY `t_sched_structure`.`order`");
			  while($line_info = mysql_fetch_assoc($lines)) {
			    $last_end = $line_info['start'];
				$end_time = $line_info['start'];
			    $structure_id = $line_info['structure_id'];
			 ?>
			  <tr> 
			   <td><img src="images/<?= $line_info['image_file'] ?>" alt="<?= $line_info['description'] ?>"></td>
			   <td><?php
			         $line = $line_info['line'];
			         $result = mysql_query("SELECT `t_sched_shifts`.`shift_id` , `t_sched_structure`.`line` , `t_sched_shifts`.`driver_id`, `t_drivers`.`firstname` , `t_drivers`.`lastname` , `t_sched_shifts`.`shift_start` , `t_sched_shifts`.`shift_end` FROM `t_sched_dates` , `t_sched_main` , `t_sched_shifts` , `t_sched_structure` , `t_drivers` WHERE `t_sched_dates`.`table_id` = `t_sched_main`.`table_id` AND `t_sched_main`.`table_id` = `t_sched_shifts`.`table_id` AND `t_sched_shifts`.`structure_id` = `t_sched_structure`.`structure_id` AND `t_sched_shifts`.`driver_id` = `t_drivers`.`driver_id` AND `t_sched_structure`.`structure_id` = $structure_id AND `t_sched_dates`.`date_id` = $date ORDER BY `t_sched_shifts`.`shift_start` ASC");
			         $first = 1;
					 if($day_start_time < $line_info["start"]) { // print filler in front of line if necessary
						 printShiftImage($day_start_time,$line_info['start'],'','F',NULL); 
					 }
			         while($shift = mysql_fetch_assoc($result)) {
			            if($first) {
						   //if($line_info['start'] 
						   printShiftImage($shift['shift_start'],$shift['shift_end'],$shift['last_name'].', '.$shift['first_name'],'S',$shift['driver_id']);
			               $last_end = $shift['shift_end'];
			               $first = 0;
						   $end_time = $shift['shift_end'];
			               continue;
			            } else if ($shift['shift_start'] == $last_end) {
			               print "<a href='javascript:shiftInfo(" . $shift['shift_id'] . ")'><img border=0 src='" . PNG_FILE . "?start=" . $shift["shift_start"] . '&end=' . $shift["shift_end"] . '&name=' . $shift['last_name'] . ', ' . $shift['first_name'] . "&type=S' alt='DRIVER_ID: " . $shift['driver_id'] . "'></a>";
			               $last_end = $shift['shift_end'];
						   $end_time = $shift['shift_end'];
			               continue;
			            } else {
			               print "<a href='javascript:shiftInfo(" . $shift['shift_id'] . ")'><img border=0 src='" . PNG_FILE . "?start=" . $last_end . '&end=' . $shift["shift_start"] . "&name=? ? ?&type=O'></a>";
			               print "<a href='javascript:shiftInfo(" . $shift['shift_id'] . ")'><img border=0 src='" . PNG_FILE . "?start=" . $shift["shift_start"] . '&end=' . $shift["shift_end"] . '&name=' . $shift['last_name'] . ', ' . $shift['first_name'] . "&type=S' alt='DRIVER_ID: " . $shift['driver_id'] . "'></a>";
			               $last_end = $shift['shift_end'];
						   $end_time = $shift['shift_end'];
			               continue;
			            }
			         }
					 if($end_time < $line_info['end']) { //show the last bit of the shift as available!
			               print "<a href='javascript:shiftInfo(" . ")'><img border=0 src='" . PNG_FILE . "?start=" . $last_end . '&end=' . $line_info["end"] . "&name=? ? ?&type=O'></a>";
						   $last_end = $line_info['end'];
						   $end_time = $line_info['end'];
					 }
					 if($end_time < $day_end_time) { //add filler to end of line
					    print "<img border=0 src='" . PNG_FILE . "?start=" . $end_time . '&end=' . $day_end_time . "&type=F' alt='Filler Image'>";
					 }
			         mysql_free_result($result);
			 ?></td>
			  </tr>
			 <?php			 
			  }
			  mysql_free_result($lines);
			 ?>
			 </table>
			 </div>
			 <div align="center">Board Generated at <?php echo date("H:i"); ?></div>
			 <div align="center">For an image key, <a href="?module=view_images">click here</a>.</div>
			 <!-- End Board Module -->
<?php
       break;
   case 'tools':
?>			 <!-- Tools Module -->
			 <table>
			   <tr>
			     <td><a href="?module=profile">Employee Profile</a></td>
			   </tr>
			   <tr>
			     <td><a href="?module=newRedstar">Generate Red Star List</a></td>
			   </tr>
			 </table>
			 
			 
<?php
       break;
   case 'profile':
?>			 <!-- Profile Module -->

			 <?php
			   $user_query = mysql_query('SELECT * FROM `t_drivers` WHERE `netid` = "' . $_SESSION['netid'] . '" LIMIT 1');
			   $user_data = mysql_fetch_assoc($user_query);
			   mysql_free_result($user_query);
			 ?>
			   
			 <h6 align="center">Employee Profile</h6>
			 <div align="center" style="margin: 5px">
			   <table cellpadding="5" cellspacing="10">
			     <tr bgcolor="#CCCCCC">
				   <td>Name</td>
				   <td><?= $user_data['firstname']?> <?= $user_data['lastname']?></td>
				 </tr>
			     <tr bgcolor="#CCCCCC">
				   <td>Net ID</td>
				   <td><?= $user_data['netid']?></td>
				 </tr>
			     <tr bgcolor="#CCCCCC">
				   <?php //calculate qualifications
				     $qualifications = array();
				     if(checkQualified('2000')) array_push($qualifications,"M");
				     if(checkQualified('1000')) array_push($qualifications,"AM");
				     if(checkQualified('0400')) array_push($qualifications,"D","AVS");
				     if(checkQualified('0100')) array_push($qualifications,"PM");
				     if(checkQualified('0200')) array_push($qualifications,"T");
				     if(checkQualified('0020')) array_push($qualifications,"SM");
				     if(checkQualified('0010')) array_push($qualifications,"B");
					 if(checkQualified('0004')) array_push($qualifications,"S","BW");
					 if(checkQualified('0001')) array_push($qualifications,"BW");
					 $qualifications = implode(",",$qualifications);
				   ?>
			       <td>Qualifications</td>
			       <td><?= $qualifications ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Seniority Points</td>
			       <td><?= $user_data['seniority']?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Email Address </td>
			       <td><?php writeAjaxUpdateField('1b2e4a850f7951428f949bd381c2f25e',driverDetail($_SESSION['driver_id'],'email'),'edit_email'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>AIM Screenname</td>
			       <td><?php writeAjaxUpdateField('7ed32b6037a460fc97a81c9e569d815b',driverDetail($_SESSION['driver_id'],'screenname'),'edit_screenname'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Campus Phone </td>
			       <td><?php writeAjaxUpdateField('e6ba6a95e92ab02920655918863e5bf8',formatPhone(driverDetail($_SESSION['driver_id'],'campusphone')),'edit_campusphone'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Cell Phone </td>
			       <td><?php writeAjaxUpdateField('a3911fb0c6cb6cc857e2aed25f17e168',formatPhone(driverDetail($_SESSION['driver_id'],'cellphone')),'edit_cellphone'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Home Phone </td>
			       <td><?php writeAjaxUpdateField('8479166e9d8fd7abf3e41a1bfebfb0b7',formatPhone(driverDetail($_SESSION['driver_id'],'homephone')),'edit_homephone'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Red Star List </td>
			       <td>NO DATA</td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Local Address </td>
			       <td><?php print $user_data['campus_street']; 
				   if($user_data['campus_street2'] != '') print "<BR>\n" .$user_data['campus_street2']; 
				   print "<BR>" . $user_data['campus_city'] . ", " . $user_data['campus_state'] . "  " . $user_data['campus_zip'];				   
				   ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Permanent Address </td>
			       <td><?php print $user_data['home_street']; 
				   if($user_data['home_street2'] != '') print "<BR>\n" .$user_data['home_street2']; 
				   print "<BR>" . $user_data['home_city'] . ", " . $user_data['home_state'] . "  " . $user_data['home_zip'];				   
				   ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Medical Card Expiration</td>
			       <td><?php writeAjaxUpdateField('adff44c5102fca279fce7559abf66fee',date("M j, Y",strtotime(driverDetail($_SESSION['driver_id'],'physicalexp'))),'edit_physicalexp'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>License Expiration</td>
			       <td><?php writeAjaxUpdateField('6209804952225ab3d14348307b5a4a27',date("M j, Y",strtotime(driverDetail($_SESSION['driver_id'],'licenseexp'))),'edit_licenseexp'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Expected Graduation Date </td>
			       <td><?php writeAjaxUpdateField('8d08068cbfbd61eae31e0c6aa4bdceec',date("M j, Y",strtotime(driverDetail($_SESSION['driver_id'],'graduationdate'))),'edit_graduationdate'); ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Last Change</td>
			       <td><?php $dateAdded = driverDetail($_SESSION['driver_id'],'dateadded'); print date("M j, Y  H:i",mktime(substr($dateAdded,8,2),substr($dateAdded,10,2),0,substr($dateAdded,4,2),substr($dateAdded,6,2),substr($dateAdded,0,4))); ?></td>
		         </tr>
			   </table>
			 </div>
			 <!-- End Profile Module -->
<?php
       break;
   case 'edit_profile':
?>			 <!-- Profile Module -->

			 <?php
			   $user_query = mysql_query('SELECT * FROM `t_drivers` WHERE `driver_id` = "' . $_SESSION['driver_id'] . '" LIMIT 1');
			   $user_data = mysql_fetch_assoc($user_query);
			   mysql_free_result($user_query);
			 ?>
			 <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
			 <input type="hidden" name="module" value="save_profile">
			 <h6 align="center">Edit Employee Profile</h6>
			 <div align="center" style="margin: 5px">
			   <table cellpadding="5" cellspacing="10">
			     <tr bgcolor="#CCCCCC">
				   <td colspan="2" style="font-size:14px; text-align:center; font-weight:bold; "><?= $user_data['firstname']?> <?= $user_data['lastname']?></td>
				 </tr>
			     <tr bgcolor="#CCCCCC">
				   <td>Net ID</td>
				   <td><?= $user_data['netid']?></td>
				 </tr>
				 <tr bgcolor="#CCCCCC">
				   <td>Nickname</td>
				   <td><input type="text" name="nickname"></td>
				 </tr>
			     <tr bgcolor="#CCCCCC">
				   <?php //calculate qualifications
				     $qualifications = array();
				     if(checkQualified(2000)) array_push($qualifications,"M");
				     if(checkQualified(1000)) array_push($qualifications,"AM");
				     if(checkQualified(0400)) array_push($qualifications,"D","AVS");
				     if(checkQualified(0100)) array_push($qualifications,"PM");
				     if(checkQualified(0200)) array_push($qualifications,"T");
				     if(checkQualified(0020)) array_push($qualifications,"SM");
				     if(checkQualified(0010)) array_push($qualifications,"B");
					 if(checkQualified(0004)) array_push($qualifications,"S","BW");
					 if(checkQualified(0001)) array_push($qualifications,"BW");
					 $qualifications = implode(",",$qualifications);
				   ?>
			       <td>Qualifications</td>
			       <td><?= $qualifications ?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Seniority Points</td>
			       <td><?= $user_data['seniority']?></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Email Address </td>
			       <td><input type="text" name="email" value="<?= $user_data['email']?>"></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Screenname</td>
			       <td><input type="text" name="screenname" value="<?= $user_data['screenname']?>"></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Campus Phone </td>
			       <td><input type="text" name="campusphone" value="<?= $user_data['campusphone'] ?>"></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Cell Phone </td>
			       <td><input type="text" name="cellphone" value="<?= $user_data['cellphone']?>"></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Home Phone </td>
			       <td><input type="text" name="homephone" value="<?= $user_data['homephone']?>"></td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Red Star List </td>
			       <td>
				   		<input type="radio" name="redstar" <?php if($user_data['redstar'] == 'c') print "selected"; ?> value="c">Cell Phone <br>
						<input type="radio" name="redstar" <?php if($user_data['redstar'] == 'l') print "selected"; ?> value="l">Campus Phone <br>
						<input type="radio" name="redstar" <?php if($user_data['redstar'] == 'h') print "selected"; ?> value="h">Home Phone 
				   </td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Local Address </td>
			       <td>
				   		<table>
							<tr>
								<td>Street</td>
								<td><input type="text" name="campus_street" value="<?= $user_data['campus_street'] ?>"></td>
							</tr>
							<tr>
								<td>Street 2</td>
								<td><input type="text" name="campus_street2" value="<?= $user_data['campus_street2'] ?>"></td>
							</tr>
							<tr>
								<td>City</td>
								<td><input type="text" name="campus_city" value="<?= $user_data['campus_city'] ?>"></td>
							</tr>
							<tr>
								<td>State, ZIP</td>
								<td><input type="text" name="campus_state" style="width: 2em; " value="<?= $user_data['campus_state'] ?>">  <input type="text" style="width: 4em; " name="campus_zip" value="<?= $user_data['campus_zip'] ?>"></td>
							</tr>
						</table>

				     </td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Permanent Address </td>
			       <td>
				   		<table>
							<tr>
								<td>Street</td>
								<td><input type="text" name="home_street" value="<?= $user_data['home_street'] ?>"></td>
							</tr>
							<tr>
								<td>Street 2</td>
								<td><input type="text" name="home_street2" value="<?= $user_data['home_street2'] ?>"></td>
							</tr>
							<tr>
								<td>City</td>
								<td><input type="text" name="home_city" value="<?= $user_data['home_city'] ?>"></td>
							</tr>
							<tr>
								<td>State, ZIP</td>
								<td><input type="text" name="home_state" style="width: 2em; " value="<?= $user_data['home_state'] ?>">  <input type="text" style="width: 4em; " name="home_zip" value="<?= $user_data['home_zip'] ?>"></td>
							</tr>
						</table>
					</td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Medical Card Expiration</td>
			       <td>
				   		<!-- M/D/Y -->
						<select name="month_medical">
							<option <?php if(substr($user_data['physicalexp'],4,2) == 1) print "selected"; ?> value="01">Jan</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 2) print "selected"; ?> value="02">Feb</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 3) print "selected"; ?> value="03">Mar</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 4) print "selected"; ?> value="04">Apr</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 5) print "selected"; ?> value="05">May</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 6) print "selected"; ?> value="06">Jun</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 7) print "selected"; ?> value="07">Jul</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 8) print "selected"; ?> value="08">Aug</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 9) print "selected"; ?> value="09">Sep</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 10) print "selected"; ?> value="10">Oct</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 11) print "selected"; ?> value="11">Nov</option>
							<option <?php if(substr($user_data['physicalexp'],4,2) == 12) print "selected"; ?> value="12">Dec</option>
						</select>
						<select name="day_medical">
							<option <?php if(substr($user_data['physicalexp'],6,2) == 1) print "selected"; ?> value="01">1</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 2) print "selected"; ?> value="02">2</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 3) print "selected"; ?> value="03">3</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 4) print "selected"; ?> value="04">4</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 5) print "selected"; ?> value="05">5</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 6) print "selected"; ?> value="06">6</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 7) print "selected"; ?> value="07">7</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 8) print "selected"; ?> value="08">8</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 9) print "selected"; ?> value="09">9</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 10) print "selected"; ?> value="10">10</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 11) print "selected"; ?> value="11">11</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 12) print "selected"; ?> value="12">12</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 13) print "selected"; ?> value="13">13</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 14) print "selected"; ?> value="14">14</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 15) print "selected"; ?> value="15">15</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 16) print "selected"; ?> value="16">16</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 17) print "selected"; ?> value="17">17</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 18) print "selected"; ?> value="18">18</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 19) print "selected"; ?> value="19">19</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 20) print "selected"; ?> value="20">20</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 21) print "selected"; ?> value="21">21</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 22) print "selected"; ?> value="22">22</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 23) print "selected"; ?> value="23">23</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 24) print "selected"; ?> value="24">24</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 25) print "selected"; ?> value="25">25</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 26) print "selected"; ?> value="26">26</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 27) print "selected"; ?> value="27">27</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 28) print "selected"; ?> value="28">28</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 29) print "selected"; ?> value="29">29</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 30) print "selected"; ?> value="30">30</option>
							<option <?php if(substr($user_data['physicalexp'],6,2) == 31) print "selected"; ?> value="31">31</option>
						</select>
						<select name="year_medical">
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2005) print "selected"; ?> value="2005">2005</option>
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2006) print "selected"; ?> value="2006">2006</option>
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2007) print "selected"; ?> value="2007">2007</option>
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2008) print "selected"; ?> value="2008">2008</option>
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2009) print "selected"; ?> value="2009">2009</option>
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2010) print "selected"; ?> value="2010">2010</option>
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2011) print "selected"; ?> value="2011">2011</option>
							<option <?php if(substr($user_data['physicalexp'],0,4) == 2012) print "selected"; ?> value="2012">2012</option>
						</select>
					</td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>License Expiration</td>
			       <td>
				   		<!-- M/D/Y -->
						<select name="month_license">
							<option <?php if(substr($user_data['licenseexp'],4,2) == 1) print "selected"; ?> value="01">Jan</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 2) print "selected"; ?> value="02">Feb</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 3) print "selected"; ?> value="03">Mar</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 4) print "selected"; ?> value="04">Apr</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 5) print "selected"; ?> value="05">May</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 6) print "selected"; ?> value="06">Jun</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 7) print "selected"; ?> value="07">Jul</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 8) print "selected"; ?> value="08">Aug</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 9) print "selected"; ?> value="09">Sep</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 10) print "selected"; ?> value="10">Oct</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 11) print "selected"; ?> value="11">Nov</option>
							<option <?php if(substr($user_data['licenseexp'],4,2) == 12) print "selected"; ?> value="12">Dec</option>
						</select>
						<select name="day_license">
							<option <?php if(substr($user_data['licenseexp'],6,2) == 1) print "selected"; ?> value="01">1</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 2) print "selected"; ?> value="02">2</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 3) print "selected"; ?> value="03">3</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 4) print "selected"; ?> value="04">4</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 5) print "selected"; ?> value="05">5</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 6) print "selected"; ?> value="06">6</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 7) print "selected"; ?> value="07">7</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 8) print "selected"; ?> value="08">8</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 9) print "selected"; ?> value="09">9</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 10) print "selected"; ?> value="10">10</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 11) print "selected"; ?> value="11">11</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 12) print "selected"; ?> value="12">12</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 13) print "selected"; ?> value="13">13</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 14) print "selected"; ?> value="14">14</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 15) print "selected"; ?> value="15">15</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 16) print "selected"; ?> value="16">16</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 17) print "selected"; ?> value="17">17</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 18) print "selected"; ?> value="18">18</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 19) print "selected"; ?> value="19">19</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 20) print "selected"; ?> value="20">20</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 21) print "selected"; ?> value="21">21</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 22) print "selected"; ?> value="22">22</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 23) print "selected"; ?> value="23">23</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 24) print "selected"; ?> value="24">24</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 25) print "selected"; ?> value="25">25</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 26) print "selected"; ?> value="26">26</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 27) print "selected"; ?> value="27">27</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 28) print "selected"; ?> value="28">28</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 29) print "selected"; ?> value="29">29</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 30) print "selected"; ?> value="30">30</option>
							<option <?php if(substr($user_data['licenseexp'],6,2) == 31) print "selected"; ?> value="31">31</option>
						</select>
						<select name="year_license">
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2005) print "selected"; ?> value="2005">2005</option>
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2006) print "selected"; ?> value="2006">2006</option>
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2007) print "selected"; ?> value="2007">2007</option>
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2008) print "selected"; ?> value="2008">2008</option>
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2009) print "selected"; ?> value="2009">2009</option>
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2010) print "selected"; ?> value="2010">2010</option>
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2011) print "selected"; ?> value="2011">2011</option>
							<option <?php if(substr($user_data['licenseexp'],0,4) == 2012) print "selected"; ?> value="2012">2012</option>
						</select>
				   </td>
		         </tr>
			     <tr bgcolor="#CCCCCC">
			       <td>Expected Graduation Date </td>
			       <td>
						<select name="graduation_date">
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200605) print "selected"; ?> value="20060501">May 2006</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200612) print "selected"; ?> value="20061201">Dec 2006</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200705) print "selected"; ?> value="20070501">May 2007</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200712) print "selected"; ?> value="20071201">Dec 2007</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200805) print "selected"; ?> value="20080501">May 2008</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200812) print "selected"; ?> value="20081201">Dec 2008</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200905) print "selected"; ?> value="20090501">May 2009</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 200912) print "selected"; ?> value="20091201">Dec 2009</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201005) print "selected"; ?> value="20100501">May 2010</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201012) print "selected"; ?> value="20101201">Dec 2010</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201105) print "selected"; ?> value="20110501">May 2011</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201112) print "selected"; ?> value="20111201">Dec 2011</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201205) print "selected"; ?> value="20120501">May 2012</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201212) print "selected"; ?> value="20121201">Dec 2012</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201305) print "selected"; ?> value="20130501">May 2013</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201312) print "selected"; ?> value="20131201">Dec 2013</option>
							<option <?php if(substr($user_data['graduationdate'],0,6) == 201405) print "selected"; ?> value="20140501">May 2014</option>
						</select>
				   </td>
		         </tr>
				 <tr>
				 	<td colspan="2" style="text-align:center; "><input type="submit" value="Save Profile"></td>
				 </tr>
			   </table>
			 </div>
			 </form>  
			 <!-- End Profile Module -->
<?php
       break;
   case 'test_design':
		if(!checkQualified("4000")) { print "You are not allowed to perform this action! (You=" . $_SESSION[permission] . " : Req'd=4000)"; break; } 

?>			 <!-- Test Design Module -->
			 <h1>Test Text H1</h1>
			 <h2>Test Text H2</h2>
			 <h3>Test Text H3</h3>
			 <h4>Test Text H4</h4>
			 <h5>Test Text H5</h5>
			 <h6>Test Text H6</h6>
			 <div class="highlight">highlight class</div>
			 <div class="italic_1">italic_1 class</div>

			 <!-- End Test Design Module -->
<?php
       break;
   case 'newRedstar':
?>			 <!-- Redstar Launch Module -->
<H6 align=center>Red Star List</H6>
<div style="margin:20px; background-color:#FFFFCC; border: 1px solid #FFFF00; padding: 10px; text-align:center; font-weight: bold;">DO NOT use these in place of a normal red star sheet from base. These are not yet acceptable.</div>

<DIV style="MARGIN: 5px" align=center>
	<p align="center">Select the shift that you need covered from the list below:</p>
	<p align="center">
  <form target="_blank" action="http://transpo.uconn.edu/redstar.php" method="post">
		<select name="shift">
			<option value="S">Shuttle</option>
			<option value="D">Dispatch</option>
		</select>
		<input type="submit" value="Create">
		<input type="hidden" name="sid" value="<?= session_id() ?>">
  </form>
	</p>
</DIV>
<?php
       break;
   case 'workswap_new':
?>			 <!-- Work Swap Module -->
<div style="margin:20px; background-color:#FFFFCC; border: 1px solid #FFFF00; padding: 10px; text-align:center; font-weight: bold;">The workswap board is currently disabled. Please use the board at base until further notice.</div>
<?php
	if(!checkQualified(1000))
		break;
?>
<SCRIPT language=javascript>
<!-- hide from old browsers

	function permPrompt() {
		document.getElementById('shiftDate').innerHTML = "PERMANENT <input type='hidden' name='perm' value='1'>";
	}
	function reloadForm() {
		location.reload();
	}

	//// THIS IS ALL THE AJAX STUFF!!!

    var http_request = false;

	function displayTimepoints() {
//	These all work in Mozilla, but no-go in IE.. :(
//		## Method 1
//		var shiftId = document.newWorkswap.line.options[document.newWorkswap.line.selectedIndex].value;
//		## Method 2
//		var shiftSelect = document.forms[0].shift;
//		var shiftId = shiftSelect.options[shiftSelect.selectedIndex].value;
//		## Attempt 3!?!?!
		var shiftId = document.getElementById("shift").options[document.getElementById("shift").selectedIndex].value
        document.getElementById("shiftTimes").innerHTML = "<p class='basicFont' style='text-align: center; font-size: 14px; font-weight: bold;'>Loading timepoints...</p>";
		makeRequest("http://transpo.uconn.edu/includes/ajax.php?task=grabTimepoints&shiftId="+shiftId,alertContents);
	}

	function resetPartialPrompt () {
		document.getElementById("shiftTimes").innerHTML = '<input type="button" value="Workswap only part of the shift" onClick="displayTimepoints()">';
	}
	
	function alertTextWarning () {
		var thisCheckbox = document.getElementById("txtnotify");
		//check if they are checking, or unchecking..
		if(thisCheckbox.checked == true) {
			//prompt the user letting them know they may incur a fee
			var acceptFee = confirm("Using this feature may cause you to incur additional fees from your cellular provider. Are you sure you want to continue?");
			if(acceptFee == false) {
				thisCheckbox.checked = false;
			}
		}
	}

    function makeRequest(url,toWhom) {
        http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest(); 
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
		
		http_request.onreadystatechange = toWhom;
        http_request.open('GET', url, true);
        http_request.send(null);
    }

    function alertContents() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                document.getElementById("shiftTimes").innerHTML = http_request.responseText;
            } else {
                alert('There was a problem with the request.');
            }
        }
    }

// -->
</SCRIPT>

<H6 align=center>Work Swap</H6>
<DIV style="MARGIN: 5px" align=center>
<TABLE>
  <TR>
    <TH>Your Name</TH>

    <TD style="text-align:left; "><?php
			if(isset($_REQUEST['driverOverride'])) {
				displayDriverSelect($_REQUEST['driverOverride'],true,"?module=workswap_new&amp;driverOverride=");
			} else {
				displayDriverSelect($_SESSION['driver_id'],true,"?module=workswap_new&amp;driverOverride=");
			} 
		?></TD></TR>
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="newWorkswap">
<input type="hidden" name="module" value="workswap_post">

  <TR>
    <TH>Your Shift</TH>
	<td style="text-align:left; ">
	  <select id=shift name=shift onChange="resetPartialPrompt()">
	    <?php
		  $driver = $_SESSION['driver_id'];
		  if(isset($driverOverride)) $driver = $driverOverride;
		  $sql = 'SELECT `t_sched_shifts` . * , `t_sched_structure` . * , t_sched_main.`order` AS "main_order", t_sched_main.description AS "main_desc", t_sched_groups.description AS "group_desc", t_sched_groups.status, t_sched_groups.group_id
				FROM t_sched_shifts, t_sched_structure, t_sched_main, t_sched_groups
				WHERE t_sched_shifts.driver_id = ' . $driver . '
				AND t_sched_shifts.table_id = t_sched_main.table_id
				AND t_sched_main.group_id = t_sched_groups.group_id
				AND t_sched_groups.status > 0
				AND t_sched_shifts.structure_id = t_sched_structure.structure_id
				ORDER BY t_sched_groups.group_id DESC , t_sched_main.main_order ASC , t_sched_structure.`order` ASC
				';
		  $query = mysql_query($sql);
		  while($row = mysql_fetch_assoc($query)) {
		    if($row['group_desc'] != $last_group) {
				$last_group = $row['group_desc'];
				print "		<option disabled>" . $row['group_desc'] . "\n";
			}
			if($row['main_desc'] != $last_main) {
				$last_main = $row['main_desc'];
				print "		<option disabled>&nbsp;&nbsp;" . $row['main_desc'] . "\n";
			}
			print "		<option value='" . $row['shift_id'] . "'>&nbsp;&nbsp;&nbsp;&nbsp;" . $row['description'] . " " . $row['shift_start'] . " - " . $row['shift_end'] . "\n";
			
		  }
		?>
	  </select>
	</td>
  </TR>

  <TR>
    <TH>Shift Date</TH>
    <TD style="text-align:left; ">
		<div id="shiftDate">
		<select name="month">
			<option value="01" <?php if(date("m") == 1) print "selected" ?>>Jan</option>
			<option value="02" <?php if(date("m") == 2) print "selected" ?>>Feb</option>
			<option value="03" <?php if(date("m") == 3) print "selected" ?>>Mar</option>
			<option value="04" <?php if(date("m") == 4) print "selected" ?>>Apr</option>
			<option value="05" <?php if(date("m") == 5) print "selected" ?>>May</option>
			<option value="06" <?php if(date("m") == 6) print "selected" ?>>Jun</option>
			<option value="07" <?php if(date("m") == 7) print "selected" ?>>Jul</option>
			<option value="08" <?php if(date("m") == 8) print "selected" ?>>Aug</option>
			<option value="09" <?php if(date("m") == 9) print "selected" ?>>Sep</option>
			<option value="10" <?php if(date("m") == 10) print "selected" ?>>Oct</option>
			<option value="11" <?php if(date("m") == 11) print "selected" ?>>Nov</option>
			<option value="12" <?php if(date("m") == 12) print "selected" ?>>Dec</option>
		</select> / 
		<select name="day">
<?php
		$count = 0;
		while($count < 31) {
			$count ++;
			if(date("d") == $count) {
				$selected = ' selected';
			} else {
				$selected = '';
			}
			print "			<option value=\"" . sprintf("%02d", $count) . "\"" . $selected . ">" . $count . "</option>\n";
		}
?>
		</select> / <INPUT size=5 name=year value="<?php echo date("Y"); ?>"> MM/DD/YYYY<BR><span style="font-size:10px;"><a href="#" onClick="permPrompt()">(To workswap permanently, click here)</a></span></TD>
		</div>
  </TR>
  <TR>
    <TH colspan="2"><div id=shiftTimes><input type="button" value="Workswap only part of the shift" onClick="displayTimepoints()"></div></TH>
  </TR>
  <tr>
    <th colspan=2>Is this a RedStar? <input type=radio name=redStar value=1> Yes <input type=radio name=redStar value=0 checked> No</th>
  </tr>
  <tr>
    <th colspan=2>Comment: <input type=text name=comment></th>

  </TR>
  <tr>
    <td colspan=2 style="text-align:center; "><table style="margin:auto; " border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th scope="row"><input type="checkbox" name="emailnotify" value="1"></th>
        <td style="text-align:left; ">Notify me by email when this shift gets covered</td>
      </tr>
      <tr>
        <th scope="row"><input type="checkbox" name="txtnotify" id="txtnotify" onClick="alertTextWarning()" value="1"></th>
        <td style="text-align:left; ">Notify me by text message when this shift gets covered</td>
      </tr>
    </table>      </td>
  </tr>
  <tr>
    <td colspan=2 style="text-align:center; "><input name="submit" type="submit" value="Post to Workswap">
      <input name="reset" type=button onClick=reloadForm() value="Reset"></td>
  </tr>
</TABLE>
</form>
</DIV>				


<?php
       break;
   case 'workswap_post':
		//yeah, that's right.. i moved it to modules.. whatcha gonna do!
		
		//logic, step 1
		if(isset($_REQUEST['shift'])) {
			//grab shift data
			$sql = sprintf("SELECT `driver_id` FROM `t_sched_shifts` WHERE `shift_id` = %s",
								quote_smart($_REQUEST['shift']));
			$result = mysql_query($sql);
			//make sure we got one, and only one result
			if(mysql_num_rows($result) != 1)
				die("Error grabbing shift data.");
			$data = mysql_fetch_assoc($result);
			mysql_free_result($result);
		} else {
			die("No shift data.");
		}
		
		//logic, step 2
		if(isset($_REQUEST['month']) and isset($_REQUEST['day']) and isset($_REQUEST['year'])) {
			//create date:
			$shift_date = sprintf("%04d%02d%02d", $_REQUEST['year'], $_REQUEST['month'], $_REQUEST['day']);
		} else {
			$shift_date = "NULL";
		}
		
		//logic, step 3
		if(($_REQUEST['redStar'] == 0) or ($_REQUEST['redStar'] == 1)) {
			$redstar = $_REQUEST['redStar'];
		} else {
			die("No red star data.");
		}
		
		//logic, step 4
		if(isset($_REQUEST['start']) and isset($_REQUEST['end'])) {
			$start = $_REQUEST['start'];
			$end = $_REQUEST['end'];
		} else {
			$start = "NULL";
			$end = "NULL";
		}
		
		//logic, step 6
		if(isset($_REQUEST['emailnotify'])) {
			$emailnotify = $_REQUEST['emailnotify'];
		} else {
			$emailnotify = 0;
		}
		
		//logic, step 7
		if(isset($_REQUEST['txtnotify'])) {
			$txtnotify = $_REQUEST['txtnotify'];
		} else {
			$txtnotify = 0;
		}
		
		//construct sql statement
		$sql = sprintf("INSERT INTO `t_workswap` (`workswap_id`,`shift_id`,`orig_driver`,`date_offered`,`shift_date`,`redstar`,`start`,`end`,`comment`,`notify_email`,`notify_text`) VALUES (0, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
							quote_smart($_REQUEST['shift']),
							quote_smart($data['driver_id']),
							date("Ymd"),
							quote_smart($shift_date),
							quote_smart($redstar),
							quote_smart($start),
							quote_smart($end),
							quote_smart($_REQUEST['comment']),
							quote_smart($emailnotify),
							quote_smart($txtnotify));
		$result = mysql_query($sql);
		$rows = mysql_affected_rows();
		if($rows == 1) {
		?>
			<div style="text-align:center; font-size:16px; ">Okay! You're shift has been posted!</div>
			<?php
			if($emailnotify)
				print "<div style='text-align:center;'>You will be notified by email if this shift is taken.</div>\n";
			if($txtnotify)
				print "<div style='text-align:center;'>You will be notified by text message if this shift is taken.</div>\n";
			
			print "<div style='text-align:center; font-size: 14px; font-weight: bold;'><a href='?module=workswap'>Return to Workswap</a></div>\n";
		} else {
			print "<!-- SQL STATEMENT: $sql \n<br>RESULT: $rows -->\n";
		}
       break;
   case 'workswap':
	?>
<div style="margin:20px; background-color:#FFFFCC; border: 1px solid #FFFF00; padding: 10px; text-align:center; font-weight: bold;">The workswap board is currently disabled. Please use the board at base until further notice.</div>
	<?php
	if(!checkQualified(1000))
		break;
?>			 <!-- Work Swap Module -->
			<script language="JavaScript" type="text/javascript">
				function confirmQuestion (continueURL,question) {
					if(confirm(question))
						document.location = continueURL;
				}
			</script>
			<h6 align="center">Work Swap</h6>
			<div align="center" style="margin: 5px">
			<p><a href="?module=workswap_new">Put Shift on Workswap</a></p>
			<table>
			<?php
				$today = date("Ymd");
				$query_string = "SELECT * 
									FROM `t_workswap`, `t_sched_shifts`, `t_drivers`, `t_sched_structure`
									WHERE (`t_workswap`.`shift_date` > $today OR `t_workswap`.`shift_date` IS NULL)
									AND `t_sched_structure`.`structure_id` = `t_sched_shifts`.`structure_id`
									AND `t_drivers`.`driver_id` = `t_sched_shifts`.`driver_id`
									AND `t_sched_shifts`.`shift_id` = `t_workswap`.`shift_id`
									ORDER BY `t_workswap`.`shift_date` ASC ";
				print "<!-- $query_string -->\n";
				$query = mysql_query($query_string);
			    //$query = mysql_query("SELECT * FROM `workswap`,`drivers` WHERE `shift_date` >= $today" . $addendum . " ORDER BY `shift_date` ASC, `shift_start` ASC WHERE `drivers`.`driver_id` = `workswap`.`driver_id_old`");
				$previousWorkSwapDay = -1;
				while($row = mysql_fetch_assoc($query)) {
			  ?>
			    <?php if($previousWorkSwapDay != $row['shift_date']) { ?>
			    <tr>
				  <td colspan=7><h6><?php print formatDate_long($row['shift_date']); ?></h6></td>
				</tr>
                <tr> 
                  <th></th>
                  <th>Shift</th>
                  <th>Current Driver</th>
                  <th>Temp/Perm</th>
				<?php if(!$openShifts) { ?>
                  <th>Driver Taking Shift</th>
                  <th>Date Taken</th>
				<?php } ?>
                  <th>Comments</th>
                </tr>
				<?php } $previousWorkSwapDay = $row['shift_date']; ?>
                <tr> 
				  <th></th>
                  <td align="center" style="padding: 3px; border: 1px solid black;"><?php if($row['redstar']) { print "<img src='/images/redstar.gif' height='15' width='15' alt='Red Starred'>"; } ?> <?php if($openShifts) { print "<a href=\"javascript:confirmQuestion('?module=workswap&task=workswap_take&wsid=" . $row['workswap_id'] . "','Taking this shift binds you to this shift. The system currently does not check to see if this will conflict with any other shifts that you are currently responsible for. Please make sure that you have checked this before continuing. Are you sure you want to take this shift?')\">"; } ?><?= $row['description'] ?> <?= $row['shift_start'] ?> - <?= $row['shift_end'] ?><?php if($openShifts) { print "</a>"; } ?> <?php if($row['redstar']) { print "<img src='/images/redstar.gif' height='15' width='15' alt='Red Starred'>"; } ?></td>
                  <td align="center" style="padding: 3px; border: 1px solid black;"><?= $row['firstname'] ?> <?= $row['lastname'] ?></td>
                  <td align="center" style="padding: 3px; border: 1px solid black;"><?php if($row['temp_perm'] == 1) { print "Perm"; } else { print "Temp"; } ?></td>
				<?php if(!$openShifts) { ?>
                  <td align="center" style="padding: 3px; border: 1px solid black;">
				  	<?php 
			if($row['new_driver'] == ''){ 
				if($row['orig_driver'] == $_SESSION['driver_id']) {
					print "<a href='#' onclick=\"confirmQuestion('?module=cancel_workswap&amp;wsid=" . $row['workswap_id'] . "','Are you sure you want to cancel this workswap?')\">Cancel</a>";
				} else {
					print "<a href='#' onclick=\"confirmQuestion('?module=take_workswap&amp;wsid=" . $row['workswap_id'] . "','Are you sure you want to take this shift?')\">Take</a>";
				}
			} else {
				$result = mysql_query("SELECT * FROM `t_drivers` WHERE `driver_id` = " . $row['new_driver']);
				$new_driver_data = mysql_fetch_assoc($result);
				print $new_driver_data['firstname'] . ' ' . $new_driver_data['lastname'];
			}
					?></td>
                  <td align="center" style="padding: 3px; border: 1px solid black;"><?php if($row['date_taken']) { print formatDate_short($row['date_taken']); } ?></td>
				<?php } ?>
                  <td align="center" style="padding: 3px; border: 1px solid black;"><?= $row['comments'] ?></td>
                </tr>
			  <?php } ?>
<!--                   <td align="center" colspan=2><a href="javascript:confirmQuestion('?module=workswap&do=takeShift&wsid=2239','Taking this shift binds you to this shift. The system currently does not check to see if this will conflict with any other shifts that you are currently responsible for. Please make sure that you have checked this before continuing. Are you sure you want to take this shift?')">Take 
 -->              </table>
			 </div>
			 <!-- End Work Swap Module -->


<?php
       break;
	case 'cancel_workswap':
		$result = mysql_query(sprintf("DELETE FROM `t_workswap` WHERE `workswap_id` = %s", quote_smart($_REQUEST['wsid'])));
		if(mysql_affected_rows() == 1) {
			?>
			<div style="text-align:center; font-size:16px; ">Workswap Cancelled!</div>
			<div style='text-align:center; font-size: 14px; font-weight: bold;'><a href='?module=workswap'>Return to Workswap</a></div>
			<?php	
		} else {
			if(mysql_affected_rows() == 0)
				$error = "Invalid Workswap Shift!";
			else
				$error = mysql_errno() . ': ' . mysql_error();
			?>
			<div style="text-align:center; font-size: 16px; ">An error occurred while cancelling your workswap.<br><span style='color: red;'>ERROR: <?= $error ?></span></div>
			<div style='text-align:center; font-size: 14px; font-weight: bold;'><a href='?module=workswap'>Return to Workswap</a></div>
			<?php	
		}
		break;
    default:
	   echo "Invalid Module";
 }
 
 function printShiftImage($start,$end,$name,$type,$driver) {
    // If the shift is a covered driving shift, and the driver == logged in user, change type
    if(($driver == $_SESSION['driver_id']) && ($type == 'S'))
	    $type = 'M';
	
	// print image
	print "<img border=0 src='" . PNG_FILE . "?start=" . $start . '&end=' . $end . "&name=" . $name . "&type=" . $type . "'></a>";
 }
 

?>